package com.example.cuibo.basicarray.cn.itcast.list;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * Created by cuibo on 2017/10/31.
 */

public class 去掉对象中重复值 {

    public static void xxx(){
        ArrayList list = new  ArrayList();
        list.add(new Teacher("1",12));
        list.add(new Teacher("1",12));
        list.add(new Teacher("1",12));
        list.add(new Teacher("1",12));
        list.add(new Teacher("1",12));


        list.remove(new Teacher("1",12));
    }

    public static ArrayList getStrin(ArrayList str){

        ArrayList newList = new ArrayList();
        Iterator it = str.iterator();
        while (it.hasNext()){
            Teacher temp = (Teacher)it.next();
            if (!newList.contains(temp)){
                newList.add(temp);
            }
        }
        return newList;
    }


}

